package data

import (
	"MyNotesWeb/bean"
)

// 根据用户名，密码获取用户信息
func Login(name string, password string) (*bean.User, error) {

	if engine, err := GetEngine(); err == nil {
		user := bean.User{}
		b, err := engine.Where("name = ? and password = ?", name, password).Get(&user)
		if b && err == nil && user.Id > 0 {
			return &user, nil
		} else {
			return nil, err
		}
	} else {
		return nil, err
	}

}
